package com.example.cuibo.elementslearning.dummy;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by cuibo on 2017/11/1.
 */

public class Demo_OldPerson {

    public static void xxx(){
        ArrayList<Person> list = new ArrayList<Person>();
        list.add(new Person("1",12));
        list.add(new Person("1",12));
        list.add(new Person("1",12));
        list.add(new Person("1",12));
    }
    /*
    * 获取集合中最老的人
    * 1.person
    * 2.LIST<Person>
    * */
    public static Person getoldPerson(List<Person> list){
        Person old = list.get(0);
        for (int i = 0; i < list.size(); i++) {
            if (old.getAge() < list.get(i).getAge()){
                old = list.get(i);
            }
        }
        
        return old;
    };
}
